package com.hy.erp.inventory.service;

import java.util.List ;

import javax.ejb.Stateless ;

import org.jboss.seam.ScopeType ;
import org.jboss.seam.annotations.Name ;
import org.jboss.seam.annotations.Scope ;

import com.hy.enterprise.architecture.foundation.ArchitectureFoundationException;
import com.hy.enterprise.framework.service.business.AbstractBusinessService;
import com.hy.erp.inventory.dao.interfaces.IDefineDepotReasonDao;
import com.hy.erp.inventory.pojo.DefineDepotReason;
import com.hy.erp.inventory.pojo.interfaces.IDefineDepotReason;
import com.hy.erp.inventory.service.interfaces.IDefineDepotReasonService;
/**
 * 
 * <ul>
 * <li>开发作者：李冰</li>
 * <li>设计日期：2010-10-13；时间：上午09:18:00</li>
 * <li>类型名称：DefineDepotReasonService</li>
 * <li>设计目的：</li>
 * </ul>
 * <ul>
 * <b>修订编号：</b>
 * <li>修订日期：</li>
 * <li>修订作者：</li>
 * <li>修订原因：</li>
 * <li>修订内容：</li>
 * </ul>
 */
@ Name ( "defineDepotReasonService" )
@ Scope ( ScopeType.STATELESS )
@ Stateless
public class DefineDepotReasonService extends AbstractBusinessService < IDefineDepotReason > implements IDefineDepotReasonService
{

	@Override
	public boolean addCustomer(IDefineDepotReason defineDepotReason) {







		if ( null == defineDepotReason)
		{
			return true ;
		}
		
		else
		{
			System.out
						.println ("ssssssssssssssssssssssffffffffffffffffhghhhhhhhhhhhhhhhhhhhhhh") ;


			IDefineDepotReasonDao defineDepotReasonDao =
			                       ( IDefineDepotReasonDao ) this
			                                          .getDao ( IDefineDepotReason.class ) ;
			
			return defineDepotReasonDao
			                .persist ( defineDepotReason ) ;
		}
		
	
	
	
	
	
	
	
	}

	@Override
	public boolean modifyDefineDepotReason(IDefineDepotReason defineDepotReason) {







		if ( ( null == defineDepotReason )
			     || ( null == defineDepotReason
			                                .getIdentifier ( ) )
			     || ( defineDepotReason
			                        .getIdentifier ( )
			                        .trim ( )
			                        .length ( ) == 0 ) )
			{
				return true ;
			}
			else
			{
				IDefineDepotReasonDao defineDepotReasonDao =
                    ( IDefineDepotReasonDao ) this
                                       .getDao ( IDefineDepotReason.class ) ;

		
					
				if ( null == defineDepotReason )
				{
					throw new ArchitectureFoundationException  (
					                                            "修改实体数据时发生错误，所需要修改的实体在数据库中并不存在" ) ;
				}
				
				
				return (defineDepotReasonDao
				                  .merge ( defineDepotReason ) != null ) ;
			}
		
	
	
	
	
	
	
	
	
	}

	@Override
	public Integer removeDefineDepotReason(String[] defineDepotReasonIds) {








		if ( ( null == defineDepotReasonIds)
			     || ( defineDepotReasonIds.length == 0 ) )
			{
				return new Integer (
				                     0 ) ;
			}
			else
			{

				IDefineDepotReasonDao defineDepotReasonDao =
                    ( IDefineDepotReasonDao ) this
                                       .getDao ( IDefineDepotReason.class ) ;

		
					
		
				return defineDepotReasonDao
				                .remove ( defineDepotReasonIds ) ;
			}
	
	
	
	
	
	
	
	
	}

	@ Override
	public String [ ] addDefineDepotReason(
									Object [ ] defineDepotReason )
	{

		if ( null == defineDepotReason)
		{
			return null ;
		}
		
		else
		{
			

			IDefineDepotReasonDao defineDepotReasonDao =
			                       ( IDefineDepotReasonDao ) this
			                                          .getDao ( IDefineDepotReason.class ) ;

			DefineDepotReason[] defineDepotReasons=new DefineDepotReason[defineDepotReason.length];
						for(int i=0;i<defineDepotReason.length;i++)
						{
							DefineDepotReason defineDepotReason2=( DefineDepotReason ) defineDepotReason[i];
							defineDepotReasons[i]=defineDepotReason2;
						}
						return defineDepotReasonDao
						                .persist ( defineDepotReasons ) ;
			
			
		}
		
	
	
	}

	@ Override
	public List < IDefineDepotReason > getAllDefineDepotReason ( )
	{

		IDefineDepotReasonDao defineDepotReasonDao =
            ( IDefineDepotReasonDao ) this
                               .getDao ( IDefineDepotReason.class ) ;
		return defineDepotReasonDao
		                .find ( );
	}

	@ Override
	public String [ ] modifyDefineDepotReason (
												Object [ ] defineDepotReason )
	{


		if ( null == defineDepotReason)
		{
			return null ;
		}
		
		else
		{
			

			IDefineDepotReasonDao defineDepotReasonDao =
			                       ( IDefineDepotReasonDao ) this
			                                          .getDao ( IDefineDepotReason.class ) ;

			DefineDepotReason[] defineDepotReasons=new DefineDepotReason[defineDepotReason.length];
						for(int i=0;i<defineDepotReason.length;i++)
						{
							DefineDepotReason defineDepotReason2=( DefineDepotReason ) defineDepotReason[i];
							defineDepotReasons[i]=defineDepotReason2;
						}
						return defineDepotReasonDao
						                .merge   ( defineDepotReasons ) ;
			
			
		}
		
	
	
	
	}

}
